#!/usr/bin/bash
# by: micro li

cur_date="`date +%02m%02d%04Y`"

echo "set package version..."
echo
sed -i -re "s|[0-9]{4,}|$cur_date|" VERSION
cvs ci -m "update package version" VERSION

rm -rf _TMP_
mkdir _TMP_
cd _TMP_

echo "check out source code..."
echo
cvs export -f -D "1/1/2018"  -d ccv cvschangeviewer

echo "generate package..."
echo
rm -rf ccv/_TST_
rm -rf ccv/ccv.design.graph.vsd
rm -rf ccv/ccv.instruction.vsd

cp ccv/INSTALL.pl .
cp ccv/README .

ccvId="ccv-2.0"
gz_file="$ccvId.tar.gz"
up_file="$ccvId-$cur_date.tar.gz"

cmd="tar -czvf $gz_file ccv/"
echo $cmd
$cmd

cmd="tar -czvf $up_file INSTALL.pl README $gz_file"
echo $cmd
$cmd

cmd="rsync -vaP -e ssh $up_file lilongen,cvschangeviewer@frs.sourceforge.net:/home/frs/project/c/cv/cvschangeviewer/"
echo $cmd
$cmd
echo 
echo

cd ..

